#include "vmon/server.h"
#include "vmon_st/st_server.h"
#include "vmon_web/web_server.h"
#include "vmon_web/servlets/file_content_servlet.h"
#include "vmon_web/servlets/swf_video_servlet.h"
#include <iostream>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int main(int argc, char* argv[])
{
    try
    {
        #ifdef _WIN32
        WORD wVersionRequested;
        WSADATA wsaData;
        int err;

        wVersionRequested = MAKEWORD( 1, 1);
        err = WSAStartup( wVersionRequested, &wsaData);

        #endif
        unsigned int port = 8888;
        vmon_web::WebServer server(port);
        server.getServletContainer().addServlet(new vmon_web::FileContentServlet());
        server.getServletContainer().addServlet(new vmon_web::SwfVideoServlet());
        server.start();
        //server.join();
        while (true) {
            string cmd;
            cout << ">> ";
            cin >> cmd;
            if (cmd == "quit") {
                break;
            }
        }
    }
    catch (const char* str)
    {
		cerr << "Failed: " << str << endl;
    }
    catch (...)
    {
        cerr << "Program aborted..." << endl;
    }

    return 0;
}

